package testcase.validationtest;

import validation.Type;
import validation.Trio;
import card.*;
import junit.framework.TestCase;

public class TrioTest extends TestCase {
	private Type trio;
	private Cardset cardset;
	/**
	* Sets up the test fixture.
	*
	* Called before every test case method.
	*/
	public void setUp() { 
		cardset = new Cardset(3);
		trio = Trio.getInstance();
	}
	
	/**
	* Tears down the test fixture.
	*
	* Called after every test case method.
	*/
	public void tearDown() {
		trio.clear();
		trio = null;
	}
	
	//Test case 1: Identify h3 s3 c3
	public void  testIdentifyThreeCard_1() {
		cardset.add(new Card('h', '3'));
		cardset.add(new Card('s', '3'));
		cardset.add(new Card('c', '3'));
		Type result = trio.identify(cardset);
		assertEquals(result, trio);
	}
	
	//Test case 2: Identify d9 c9 h9
	public void  testIdentifyThreeCard_2() {
		cardset.add(new Card('d', '9'));
		cardset.add(new Card('c', '9'));
		cardset.add(new Card('h', '9'));
		Type result = trio.identify(cardset);
		assertEquals(result, trio);
	}
	
	//Test case 3: Identify cX dX sX
	public void  testIdentifyThreeCard_3() {
		cardset.add(new Card('c', 'X'));
		cardset.add(new Card('d', 'X'));
		cardset.add(new Card('s', 'X'));
		Type result = trio.identify(cardset);
		assertEquals(result, trio);
	}
	
	//Test case 4: Identify cA s6 hQ
	public void  testIdentifyThreeCard_4() {
		cardset.add(new Card('c', 'A'));
		cardset.add(new Card('s', '6'));
		cardset.add(new Card('h', 'Q'));
		Type result = trio.identify(cardset);
		assertEquals(result, null);
	}
	
	//Test case 5: Identify dQ hQ s6
	public void  testIdentifyThreeCard_5() {
		cardset.add(new Card('d', 'Q'));
		cardset.add(new Card('h', 'Q'));
		cardset.add(new Card('s', '6'));
		Type result = trio.identify(cardset);
		assertEquals(result, null);
	}
	
	//Test case 6: Identify h5 s5 s4 d4
	public void  testIdetnifyFourCards() {
		cardset.add(new Card('h', '5'));
		cardset.add(new Card('s', '5'));
		cardset.add(new Card('s', '4'));
		cardset.add(new Card('d', '4'));
		Type result = trio.identify(cardset);
		assertEquals(result, null);
	}
	
	//Test case 7: Compare 444 to 555
	public void  testPriority_1() {
		cardset.add(new Card('h', '5'));
		cardset.add(new Card('s', '5'));
		cardset.add(new Card('d', '5'));
		Cardset temp = new Cardset(3);
		temp.add(new Card('s', '4'));
		temp.add(new Card('d', '4'));
		temp.add(new Card('c', '4'));
		trio.lessPriorityThan(cardset);
		boolean result = trio.lessPriorityThan(temp);
		assertEquals(result, false);
	}	

	//Test case 8: Compare AAA to QQQ
	public void  testPriority_2() {
		cardset.add(new Card('h', 'Q'));
		cardset.add(new Card('s', 'Q'));
		cardset.add(new Card('d', 'Q'));
		Cardset temp = new Cardset(3);
		temp.add(new Card('s', 'A'));
		temp.add(new Card('d', 'A'));
		temp.add(new Card('c', 'A'));
		trio.lessPriorityThan(cardset);
		boolean result = trio.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	//Test case 9: Compare 222 to 666
	public void  testPriority_3() {
		cardset.add(new Card('h', '6'));
		cardset.add(new Card('s', '6'));
		cardset.add(new Card('d', '6'));
		Cardset temp = new Cardset(3);
		temp.add(new Card('s', '2'));
		temp.add(new Card('d', '2'));
		temp.add(new Card('c', '2'));
		trio.lessPriorityThan(cardset);
		boolean result = trio.lessPriorityThan(temp);
		assertEquals(result, true);
	}
}
